﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;

namespace LearnEnglishWords.UI.ViewModels
{
    public class DashboardViewModel : BaseViewModel
    {
        private List<Domain.CircleLookup> _circleLookups;

        public List<Domain.CircleLookup> CircleLookups
        {
            get { return _circleLookups; }
            set { _circleLookups = value; NotifyOfPropertyChange(); }
        }

        protected override async void OnActivate()
        {
            base.OnActivate();

            CircleLookups = await _circlesModel.GetCircleLookups();

            Demo();
        }

        private async void Demo()
        {
            if (CircleLookups == null || CircleLookups.Count == 0)
            {
                await _circlesModel.SaveNewCircle("test test test test");
                foreach (var word in Models.WordExamples.Samples)
                {
                    await _circlesModel.SaveNewWord(word.EnglishWord, word.RussianWord, word.Examples);
                }

                CircleLookups = await _circlesModel.GetCircleLookups();
            }
        }

        public async void ShowCircleDetails(Domain.CircleLookup circleLookup)
        {
            await _circlesModel.SetAsCurrentCircle(circleLookup.Id);
            _navigationService.NavigateToViewModel<WordDemostrationViewModel>();
        }
    }
}
